<template>
  <el-form>
    <el-row :gutter="3" class="m-contain">
      <el-col :span="tableCol.col[0]" :offset="tableCol.offset">
        <el-form-item label="省份" class="u-ipt" required label-width="50px">
          <el-select
            @change="proSelectChange"
            v-model="queryData.proSelect"
            placeholder="请选择"
            class="m-select"
          >
            <el-option
              v-for="item in proList"
              :key="item.commonRegionId"
              :label="item.regionName"
              :value="item.commonRegionId"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="tableCol.col[1]">
        <el-form-item label="地市" class="u-ipt" required label-width="50px">
          <el-select
            @change="citySelectChange"
            v-model="queryData.citySelect"
            placeholder="请选择"
            class="m-select"
          >
            <el-option
              v-for="item in cityList"
              :key="item.commonRegionId"
              :label="item.regionName"
              :value="item.commonRegionId"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="tableCol.col[2]" v-if="tableCol.custIsShow">
        <el-form-item label="省客户ID" class="u-ipt" required label-width="80px">
          <el-input
            placeholder="请输入内容"
            v-model="queryData.proId"
            class="input-with-select"
          ></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="tableCol.col[3]" v-if="tableCol.amountIsShow">
        <el-form-item :label="tableCol.label" class="u-ipt" required label-width="80px">
          <el-input
            placeholder="请输入内容"
            v-model="queryData.proAId"
            class="input-with-select"
          ></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="2" v-if="tableCol.checkShow">
        <el-button class="checkBtn" @click="checkBtn"> {{btnText ? btnText : '查询'}} </el-button>
      </el-col>
    </el-row>
  </el-form>
</template>

<script>
import CustRelationManage from "@/api/customer/CustRelationManage";
export default {
  props:{
    btnText:{
      type:String,
      default:''
    },
    tableCol:{
      type:Object,
      default:{}
    },
    queryData:{
      type:Object,
      default:{}
    }
  },
  data() {
    return {
      // queryData: {
      //   proSelect: "", //选择的省
      //   citySelect: "", //选择的城市
      //   proId: "", //省客户id
      //   proAId:"",//省账户id
      // },
      proList: [], //省列表
      cityList: [], //城市列表
    };
  },

  components: {},

  mounted() {
    this.getProvinceList();
  },

  methods: {
    async getProvinceList() {
      const response = await CustRelationManage.getProvinceList();
      if (response.code == 200) {
        this.proList = response.meta;
      }
    },
    async getLanList(val) {
      const response = await CustRelationManage.getLanList({
        parRegionId: val,
      });
      if (response.code == 200) {
        this.cityList = response.meta;
      }
    },
    //查询省客户
    async checkBtn() {
      if(this.btnText){
        if(this.queryData.proSelect == ''){
           this.$alert('省份:不能为空!','提示',{type:'warning'})
           return
        }
        this.$emit('innerDigShow',this.queryData);
      }else {
        this.$emit('getCustList',this.queryData);
      }
    },
    proSelectChange(val) {
      this.queryData.citySelect = '';
      this.getLanList(val);
    },
    citySelectChange(val) {
      
    },
  },
};
</script>
<style lang='scss' scoped>
.checkBtn {
  background: #467cd4;
  color: #fff;
}
</style>